import { useSelector } from "react-redux"
import { Navigate, useLocation } from 'react-router-dom'
function Auth({ children }) {
    const location = useLocation()
    const state = useSelector(state => state.user)
    if (state.token) {
        return (
            <>
                {children}
            </>
        )
    } else {
        return <Navigate to={"/login?next=" + location.pathname} />
    }

}
export default Auth